package com.xy.day4.dao;


import java.util.List;

import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.mybatis.spring.annotation.MapperScan;
import com.xy.day4.entity.Type;
import com.xy.day4.util.RedisCache;


@MapperScan
@CacheNamespace(implementation=RedisCache.class)
public interface TypeMapper {
    @Delete({
        "delete from type",
        "where type_id = #{typeId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer typeId);

    @Insert({
        "insert into type (type_id, type_name)",
        "values (#{typeId,jdbcType=INTEGER}, #{typeName,jdbcType=VARCHAR})"
    })
    int insert(Type record);

    int insertSelective(Type record);

    @Select({
        "select",
        "type_id, type_name",
        "from type",
        "where type_id = #{typeId,jdbcType=INTEGER}"
    })
    @ResultMap("com.xy.day4.dao.TypeMapper.BaseResultMap")
    Type selectByPrimaryKey(Integer typeId);

    @Select({
        "select",
        "type_id, type_name",
        "from type"
    })
    @ResultMap("com.xy.day4.dao.TypeMapper.BaseResultMap")
    List<Type> selectAll();
    
    int updateByPrimaryKeySelective(Type record);

    @Update({
        "update type",
        "set type_name = #{typeName,jdbcType=VARCHAR}",
        "where type_id = #{typeId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Type record);
}